﻿using System;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Quiz_Builder.Helpers;
using Quiz_Builder.Model;
using Quiz_Builder.ViewModel.TestTypes;

namespace Quiz_Builder.ViewModel
{
    internal class MainViewModel : BaseViewModel
    {
        #region Fields
        private TestType _selectedTestType;
        #endregion
        #region Properties
        public Array TestTypes;
        public TestType SelectedTestType
        {
            get { return _selectedTestType; }
            set
            {
                _selectedTestType = value;
                RaisePropertyChanged("SelectedTestType");
            }
        }
        #endregion
        #region Commands

        public ICommand SaveTestCommand { get; set; }
        #endregion

        public MainViewModel()
        {
            TestTypes = Enum.GetValues(typeof (TestType));
            InitCommands();
        }

        #region Methods
        private void InitCommands()
        {
            SaveTestCommand = new RelayCommand(OnSaveTest);
        }

        private void OnSaveTest(object obj)
        {
            var test = new TrueFalse();
            test.QuestionText = "London is a capital of GB?";
            test.MediaUrl = "london.jpg";
            test.Answers = new ObservableCollection<AnswerRadioItem>();
            var answ1 = new AnswerRadioItem();


            answ1.IsChecked = true;
            answ1.Text = "Yes";
            test.Answers.Add(answ1);
            answ1 = new AnswerRadioItem();
            answ1.IsChecked = false;
            answ1.Text = "No";
            test.Answers.Add(answ1);

            string xml = XmlHelper.ObjectToXml(test);
        }
       
        #endregion
    }
}